﻿using M_Manufacture.API.Application.Command.WorkOrderCommand;
using M_Manufacture.Repository.Interface;
using MediatR;

namespace M_Manufacture.API.Application.CommandHandlers.WorkOrderCommandHandler
{
    /// <summary>
    /// 新增工单
    /// </summary>
    public class CreateWorkOrderCommandHandler : IRequestHandler<CreateWorkOrderCommand, int>
    {
        private readonly IWorkOrderRepository _workOrderRepository;
        public CreateWorkOrderCommandHandler(IWorkOrderRepository workOrderRepository)
        {
            _workOrderRepository = workOrderRepository;
        }
        public async Task<int> Handle(CreateWorkOrderCommand request, CancellationToken cancellationToken)
        {
            return await _workOrderRepository.AddAsync(request);
        }
    }
}
